package com.liming.order.controller;

import com.liming.common.pojo.dto.order.admin.RefundPageQuery;
import com.liming.common.pojo.vo.PageVO;
import com.liming.common.pojo.vo.order.web.RefundOrderVO;
import com.liming.common.result.LMResult;
import com.liming.order.service.RefundOrderMircoService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author liming
 * @date 2025/4/14
 */
@RestController
@AllArgsConstructor
@RequestMapping("/service/admin-refund-order")
public class AdminRefundOrderMircoController {

    private final RefundOrderMircoService refundOrderMircoService;

    @Operation(summary = "分页 - 退款")
    @GetMapping("refund")
    public LMResult<PageVO<RefundOrderVO>> refundPage(RefundPageQuery query) {
        return LMResult.success(refundOrderMircoService.refundPage(query));
    }

    @Operation(summary = "同意退款 - 订单")
    @PutMapping("agreeRefund/{id}")
    public LMResult<Boolean> agreeRefund(@PathVariable("id") Long refundOrderId) {
        return LMResult.success(refundOrderMircoService.agreeRefund(refundOrderId));
    }

    @Operation(summary = "拒绝退款 - 订单")
    @PutMapping("refuseRefund/{id}")
    public LMResult<Boolean> refuseRefund(@PathVariable("id") Long refundOrderId, @RequestParam String reason) {
        return LMResult.success(refundOrderMircoService.refuseRefund(refundOrderId, reason));
    }

    @Operation(summary = "查询退款 - 订单")
    @PutMapping("queryRefund/{id}")
    public LMResult<Boolean> queryRefund(@PathVariable("id") Long refundOrderId) {
        return LMResult.success(refundOrderMircoService.queryRefund(refundOrderId));
    }
}
